class Response {
    constructor({
        code = 200,
        msg = '',
        data = {}
    }, ctx = {}) {
        this.success = code && code === 200 ? true : false
        this.code = code
        this.msg = msg
        this.data = data
        this.time = +(new Date),
            this.req = ctx
    }
    toJson() {
        return {
            success: this.success,
            code: this.code,
            msg: this.msg,
            data: this.data,
            time: this.time,
            req: this.req
        }
    }
}

export default Response